<?php
/*********************************************
  CPG DragonflyCMS, Copyright (c) 2011 by DragonflyCMS Dev Team
  http://dragonflycms.org
  Released under GNU GPL version 2 or any later version
**********************************************/
if (!defined('CPG_NUKE')) { exit; }

if ('POST' === $_SERVER['REQUEST_METHOD']) { Dragonfly_Net_Http::headersFlush(400); }
if (!preg_match('#^[a-z][a-z0-9_\-]+$#i', $_GET['feed'])) { Dragonfly_Net_Http::headersFlush(404); }

$type = 'rss';
//if (isset($_GET['type'])) {
//	if ('rss' != $_GET['type']/* && 'atom' != $_GET['type']*/) { Dragonfly_Net_Http::headersFlush(404); }
//	$type = $_GET['type'];
//}

require_once(CLASS_PATH. 'feed_' .$type .'.php');
SynFeed::$category = $_GET['feed'];

//if (isset($_GET['ver'])) {
//	if (!preg_match('#^[\d]\.[\d]$#', $_GET['ver'])) { Dragonfly_Net_Http::headersFlush(404); }
//	SynFeed::$version = $_GET['ver'];
//}

if (is_file(MODULE_PATH .SynFeed::$category .DIRECTORY_SEPARATOR .'feed_' .$type .'.inc')) {
	require_once(CORE_PATH .'cmsinit.inc');
	require_once(CORE_PATH .'functions' .DIRECTORY_SEPARATOR .'language.php');
	require_once(CORE_PATH .'nbbcode.php');
	header('Content-Type: text/xml; charset=utf-8'); // application/rss+xml
	require_once(MODULE_PATH .SynFeed::$category .DIRECTORY_SEPARATOR .'feed_' .$type .'.inc');
	exit;
}
Dragonfly_Net_Http::headersFlush(404);